package com.example.weizix.ui.fragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.weizix.R;
import com.example.weizix.base.BaseLazyLoadFragment;
import com.example.weizix.bean.DailyBean;
import com.example.weizix.presenter.HotPresenter;
import com.example.weizix.ui.adapter.DailAdapter;
import com.example.weizix.view.HotView;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * A simple {@link Fragment} subclass.
 */
public class HotFragment extends BaseLazyLoadFragment<HotPresenter> implements HotView {
    @BindView(R.id.rel)
    RecyclerView rel;
    private DailAdapter adapter;

    public HotFragment() {
        // Required empty public constructor
    }

    public static HotFragment getInstance() {
        HotFragment fragment = new HotFragment();
        return fragment;
    }

    @Override
    protected int getLayout() {
        return R.layout.fragment_hot;
    }

    @Override
    protected void initListener() {

    }

    @Override
    protected void initData() {
        mPresenter.getHot();
    }

    @Override
    protected void initView(View inflate) {
        rel.setLayoutManager(new LinearLayoutManager(getContext()));
        ArrayList<DailyBean.RecentBean> list = new ArrayList<>();
        adapter = new DailAdapter(getContext(),list);
        rel.setAdapter(adapter);

    }

    @Override
    protected HotPresenter initPresenter() {
        return new HotPresenter();
    }

    @Override
    public void setData(List<DailyBean.RecentBean> recent) {
        adapter.addData(recent);
    }
}
